<!--
// 
// EndDate.vue
// hs-admin
// 
// 2024/11/11.
// 
-->
<template>
    <div class="EndDate">
        <template v-if="endDate">
            <el-tag v-if="$dayjs(endDate).diff($dayjs(), 'day') >= 7" type="success">{{endDate}}</el-tag>
            <el-tag v-if="$dayjs(endDate).diff($dayjs(), 'day') < 7 && $dayjs(endDate).diff($dayjs(), 'day') > 0" type="warning">{{endDate}}</el-tag>
            <el-tag v-if="$dayjs(endDate).diff($dayjs(), 'day') <= 0" effect="dark" type="danger">{{endDate}}</el-tag>
        </template>
    </div>
</template>

<script setup>
import {ref, reactive, computed, onMounted} from "vue";
import {useStore} from "vuex";
import {useRouter} from "vue-router";

const {$dayjs} = window;

const props = defineProps({
    item: {
        type: Object,
        default: () => {
            return {};
        }
    }
});
const emits = defineEmits();

// 路由
const router = useRouter();
// store
const store = useStore();
const endDate = computed(() => {
    let date = ""
    if (props.item.authorizationType===1) {
        date = "9999-12-30 23:59:59";
    } else if (props.item.authorizationType===2) {
        date = $dayjs().add(props.item.remainingDays || 0, "day").format("YYYY-MM-DD 23:59:59");
    } else if (props.item.authorizationType===3) {
        date = $dayjs(props.item.deadline).format("YYYY-MM-DD HH:mm:ss");
    } else {
        date = null;
    }
    return date;
})

</script>

<style scoped lang="scss">
.EndDate {
}
</style>